/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package millenium3dchess;

import java.io.IOException;

/**
 *
 * @author Kenneth
 */
public class Game {

    public static enum Color {
        WHITE, BLACK;
    }
    
    private static final GameSquare[][][] board = new GameSquare[3][8][8];
    public final static Display display = new GuiDisplay();
    private final static Player player1 = new Human(board, Color.WHITE);
    private static Color turn;

    public static GameSquare[][][] getBoard() {
        return board;
    }

    public static Color getTurn() {
        return turn;
    }

    //increments to and returns the next turn color
    public static Color nextTurn() {
        if (turn == Color.WHITE) {
            turn = Color.BLACK;
        } else {
            turn = Color.WHITE;
        }
        return turn;
    }
    
    public static Gamevector convertStringToVector(String s) {
        int lr = 0;
        switch (s.charAt(1)) {
            case 'a':
                lr = 0;
                break;
            case 'b':
                lr = 1;
                break;
            case 'c':
                lr = 2;
                break;
            case 'd':
                lr = 3;
                break;
            case 'e':
                lr = 4;
                break;
            case 'f':
                lr = 5;
                break;
            case 'g':
                lr = 6;
                break;
            case 'h':
                lr = 7;
                break;
        }
        return new Gamevector(Integer.parseInt(String.valueOf(s.charAt(0))) - 1,
                lr, Integer.parseInt(String.valueOf(s.charAt(2))) - 1);
    }
    
    public static void main(String[] args) throws IOException {
        turn = Color.BLACK;
        for (int z = 0; z < 3; z++) {
            for(int x = 0; x < 8; x++){
            for(int y = 0; y < 8; y++){                
                    Gamevector vec = new Gamevector(z,y,x);
                    if(z == 0 && x == 1){//set the pawns
                        board[z][y][x] = new GameSquare(vec, new Pawn(vec, Color.WHITE), turn);
                    }else if(z == 2 && x == 6){
                        board[z][y][x] = new GameSquare(vec, new Pawn(vec, Color.BLACK), turn);
                    }else if(z == 0 && x == 0){
                        if(y == 0 || y == 7)board[z][y][x] = new GameSquare(vec, new Rook(vec, Color.WHITE), turn);
                        if(y == 1 || y == 6)board[z][y][x] = new GameSquare(vec, new Knight(vec, Color.WHITE), turn);
                        if(y == 2 || y == 5)board[z][y][x] = new GameSquare(vec, new Bishop(vec, Color.WHITE), turn);
                        if(y == 3) board[z][y][x] = new GameSquare(vec, new Queen(vec, Color.WHITE), turn);
                        if(y == 4) board[z][y][x] = new GameSquare(vec, new King(vec, Color.WHITE), turn);
                    }else if(z == 2 && x == 7){
                        if(y == 0 || y == 7)board[z][y][x] = new GameSquare(vec, new Rook(vec, Color.BLACK), turn);
                        if(y == 1 || y == 6)board[z][y][x] = new GameSquare(vec, new Knight(vec, Color.BLACK), turn);
                        if(y == 2 || y == 5)board[z][y][x] = new GameSquare(vec, new Bishop(vec, Color.BLACK), turn);
                        if(y == 3) board[z][y][x] = new GameSquare(vec, new Queen(vec, Color.BLACK), turn);
                        if(y == 4) board[z][y][x] = new GameSquare(vec, new King(vec, Color.BLACK), turn);
                    }else{
                        board[z][y][x] = new GameSquare(vec, null, turn);
                    }
                    if(y != 7) nextTurn();
                }
            }
        }
        display.display();
    }
}
